<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2023/5/11
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%String path = request.getContextPath()+"/";%>
<html>
<head>
    <base href="<%=path%>">
    <title>角色列表</title>
    <link rel="stylesheet" href="hplus/static/bootstrap-table.min.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <link rel="stylesheet" href="https://unpkg.com/@fortawesome/fontawesome-free@5.12.1/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
    <style>
        .row{
            background-color: #FFFFFF;
            margin: 10px 10px;
            border-radius: 10px;
            box-shadow:1px 1px 3px #8c8c8c;
            padding-top: 7px;
        }
    </style>
</head>
    <style>
    .a{
        background-color: #0d8ddb;
    }
</style>
<body>
<div class="container" style="background-color: #f3f3f4;width:100%">
    <div class="row" style="">
        <div class="col-xs-12 col-lg-12" >
            <form method="get" action="user/list" id="searchForm" class="form-inline">
                <div class="form-group">
                    <label >角色名称:</label>
                    <input type="text" class="form-control" name="roleName" >
                </div>
                <div class="form-group">
                    <label >状态:</label>
                    <select name="status" class="form-control">
                        <option value="-1">全部</option>
                        <option value="0"  >启用</option>
                        <option value="1" >停用</option>
                    </select>
                </div>
                <button class="btn btn-primary" type="button" onclick="$.table.search()">搜索</button>
                <button class="btn btn-primary" type="button" onclick="$.table.reset()">重置</button>
            </form>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12 col-lg-12">
            <table id="table">
            </table>
            <div id="toolbar" style="padding-left:5px;">
                <shiro:hasPermission name="user:add">
                     <button class="btn btn-primary" onclick="$.modal.openWin('新增角色信息','role/toEdit','500px','500px');"><span class="glyphicon glyphicon-plus"></span>新增</button>
                </shiro:hasPermission>
                    <shiro:hasPermission name="user:delete">
                    <button class="btn btn-warning" onclick="$.operator.deletes('role/deletes');"><span class="glyphicon glyphicon-trash"></span>批量删除</button>
                    </shiro:hasPermission>
            </div>
        </div>
    </div>
</div>
</body>
<script src="hplus/static/bootstrap-table.min.js"></script>
<script type="text/javascript" src="hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
<script src="hplus/js/plugins/layer/layer.min.js" type="text/javascript"></script>
<script src="hplus/js/sofwin.js"></script>
<script>

    $(function() {
        var columns = [
            {
                checkbox: true,
            },{
                field: 'roleName',
                title: '角色名称',
                visible: true
            },{
                field: 'permission',
                title:'权限字符',
                width: 300,
                halign: 'center',
                align: 'right'
            },{
                field:'sort',
                title:'排序'
            },
            {
                field:'status',
                title:'状态',
                formatter:function(a,b,c,d) {
                    if (a == 0) {
                        return '<span class="label label-success">可用</span>';
                    }
                    return '<span class="label label-danger">停用</span>';
                }

            },{
                title: '操作',
                width: 200,
                align: "center",
                formatter:function(a,b,c,d){
                    console.info(b)
                    var editUrl='$.modal.openWin(\'编辑角色信息\',\'role/toEdit?id='+b.id+'\');';
                    var deleteUrl='$.operator.delete(\'role/delete/'+b.id+'\')';
                    var qxUrl='$.modal.openWin(\'设置权限\',\'role/tree?roleId='+b.id+'\');';
                    var str= '<a class="btn btn-xs btn-primary" onclick="'+editUrl+'">编辑</a>&nbsp;&nbsp;'+
                        '<a class="btn btn-xs btn-primary" onclick="'+deleteUrl+'">删除</a>&nbsp;'+
                        '<a class="btn btn-xs btn-primary" onclick="'+qxUrl+'">设置权限</a>&nbsp;';
                    console.info(str)
                    return str;
                }
            }
        ];
        $.table.initTable(columns,'role/data');
    })
</script>
</html>
